////////////////////////////////////////////////
// 设备配置
// 吴野
// 2024-05-28 15:13:49
////////////////////////////////////////////////
<script>
const Prop = {}
export default {
    props: Prop,
    data() {
        return {
            modalShow: false,
            modaleStatus: '设备配置',
            formValidate: {
                gpyxh: '',
                zjxh: ''
            },
            ruleValidate: {
                // gpyxh: [
                //     { required: true, message: 'Please select the city', trigger: 'change' }
                // ],
            },
            userId: ''
        };
    },
    mounted() {
        this.$http.$post('AccountLoginInfo', { data: {} }).then(async res => {
            if (res.code == 200) {
                let userInfo = res.data;
                this.formValidate.gpyxh = userInfo.extend.gpyxh ? userInfo.extend.gpyxh : '';
                this.formValidate.zjxh = userInfo.extend.zjxh ? userInfo.extend.zjxh : '';
            }
        })
    },

    methods: {
        init() {
            this.modalShow = !this.modalShow;
        },
        close() {
            this.modalShow = false;
        },
        onSelectChange(val, obj) {
            if (val == '光阵WJ1203') {
                this.formValidate.zjxh = "光阵WJ1203(身份证读卡器)"
            }
        },
        submit() {
            this.$refs.formValidate.validate((valid) => {
                if (valid) {
                    let userInfo = icu.storage.getData('userInfo');
                    this.$http.$get('updateDevice', {
                        params: {
                            userId: userInfo.id, zjxh: this.formValidate.zjxh, gpyxh: this.formValidate.gpyxh
                        }
                    }).then(res => {
                        if (res.code == 200) {
                            icu.storage.setData([
                                {
                                    key: 'configSB',
                                    value: this.formValidate
                                }
                            ]);
                            this.$Message.success('保存成功！');
                            this.close()
                        }
                    })
                }
            })
        }
    },
    watch: {}
}
</script>
<template>
    <div id='' class='i_configuration'>
        <Modal v-model="modalShow" width="600" :mask-closable="false" :title="modaleStatus">
            <div v-if="modalShow" style="height: 250px;overflow: auto;">
                <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="120">
                    <FormItem label="高拍仪" prop="gpyxh">
                        <Select v-model="formValidate.gpyxh" placeholder="请选择" clearable @on-change="onSelectChange">
                            <Option value="捷宇D5A3T-100U">捷宇D5A3T-100U</Option>
                            <Option value="维山XHA9373">维山XHA9373</Option>
                            <Option value="维山XH9542">维山XH9542</Option>
                            <Option value="光阵WJ1203">光阵WJ1203</Option>
                            <Option value="紫光UnisproG760">紫光UnisproG760</Option>
                            <Option value="点易拍E1260DS">点易拍E1260DS</Option>
                        </Select>
                    </FormItem>
                    <FormItem label="身份证读卡器" prop="zjxh">
                        <Select v-model="formValidate.zjxh" placeholder="请选择" clearable>
                            <Option value="神思二代SS628(100)">神思二代SS628(100)+光阵WJ1203内置读卡器</Option>
                            <!-- <Option value="光阵WJ1203(身份证读卡器)">光阵WJ1203(身份证读卡器)</Option> -->
                            <!-- <Option value="捷宇XH500ZB">捷宇XH500ZB</Option>
                            <Option value="维山XHA9373">维山XHA9373</Option>
                            <Option value="维山XH9542">维山XH9542</Option>
                            <Option value="光阵WJ1203">光阵WJ1203</Option> -->
                        </Select>
                    </FormItem>
                </Form>
            </div>
            <div slot="footer">
                <Button @click="close">关闭</Button>
                <Button type="primary" @click="submit">确定</Button>
            </div>
        </Modal>
    </div>
</template>
<style lang='less' scoped>
</style>